using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class DoctorRegRelMap : EntityTypeConfiguration<DoctorRegRel>
	{
		public DoctorRegRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("DoctorRegRels");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DoctorId).HasColumnName("DoctorId");
			this.Property(t => t.RegistrationId).HasColumnName("RegistrationId");

			// Relationships
			this.HasRequired(t => t.Doctor)
				.WithMany(t => t.DoctorRegRels)
				.HasForeignKey(d => d.DoctorId);
				
			this.HasRequired(t => t.PatientReg)
				.WithMany(t => t.DoctorRegRels)
				.HasForeignKey(d => d.RegistrationId);
				
		}
	}
}

